home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / fortran / libry51.zip / LIBRY4B.DOC < prev    next >
Text File  |  1989-11-10  |  20KB  |  480 lines

  1. .pa
  2.                  QUICK LIST OF MATHEMATICAL SUBROUTINES
  3.  
  4. BFNLQ.... brute force method for nonlinear simultaneous equations (see BRYDN)
  5. BFNLQD... double precision version of BFNLQ (see BRYDN)
  6. BRYDN.... modified Broyden's method for nonlinear simultaneous equations
  7. BRYDND... double precision version of BRYDN
  8. CONJG.... conjugate gradient method for nonlinear simult. equns. (see BRYDN)
  9. CONJGD... double precision version of CONJG (see BRYDN)
  10. CUBIC.... solve a cubic equation
  11. CUBICD... double precision form of CUBIC
  12. FMIN..... find the minimum of a function within an interval
  13. FMIND.... double precision version of FMIN
  14. FZERO.... find the zero (root) of a function within an interval
  15. FZEROD... double precision version of FZERO
  16. GAUSP.... Gauss-Jordan elimination of simultaneous equations
  17. GAUSPD... double precision form of GAUSP
  18. JLDAY.... convert month/day/year to Julian (annual) day
  19. LLSLC.... linear least-squares with linear constraints
  20. LNREG.... linear regression
  21. MADD..... matrix addition
  22. MADDD.... double precision matrix addition
  23. MCPY..... matrix copy
  24. MCPYD.... double precision matrix copy
  25. MDAY..... convert Julian (annual) day to month/day/year
  26. MINV..... matrix inversion
  27. MINVD.... double precision form of MINV
  28. MPRD..... matrix product (multiplication)
  29. MPRDD.... double precision matrix product (multiplication)
  30. MSUB..... matrix subtraction
  31. MSUBD.... double precision matrix subtraction
  32. MTRA..... matrix transpose
  33. MTRAD.... double precision matrix transpose
  34. MTRS..... in-place transpose of a square matrix
  35. MTRSD.... in-place transpose of a double precision square matrix
  36. NTNLQ.... Newton's method for nonlinear simultaneous equations (see BRYDN)
  37. NTNLQD... double precision version of NTNLQ (see BRYDN)
  38. PROOT.... polynomial root finder
  39. QUAD..... solve a quadratic
  40. QUADD.... double precision form of QUAD
  41. RAND..... random number generator (real)
  42. RK4...... 4th order Runge-Kutta (solution of ordinary differential eqns.)
  43. RK6D..... 6th order Runge-Kutta (solution of ordinary differential eqns.)
  44. SPLNE.... determine coefficients for a cubic spline
  45. SVD...... singular value decomposition using Householder transformations
  46. TDIAG.... tridiagonal matrix solver
  47. TDIAGD... double precision form of TDIAG
  48. TREND.... compute trend of periodic function
  49.  
  50. NOTE: A word of caution about matrix operation subroutines.  All of these
  51.       routines (MADD, MSUB, MCPY, MPRD, MSUB, MTRA, MTRS and their double
  52.       precision  counterparts)  use vector emulations.  Subsequently,  no
  53.       arrays  can  cross  a segment boundary.  See  Chapter  7  for  more
  54.       cautions.
  55. .pa
  56.                            MATHEMATICAL SUBROUTINES
  57.  
  58.  
  59. NAME:     BRYDN
  60. PURPOSE:  modified Broyden's method for nonlinear simultaneous equations
  61. TYPE:     subroutine (far external)
  62. SYNTAX:   CALL BRYDN(USER,XMIN,XMAX,X,F,N,M,WORK,MW,MCALL,IPRT,IER)
  63. IMPUT:    USER (far external) a subroutine that YOU MUST PROVIDE and
  64.           must be called by the sequence CALL USER(X,F)
  65.           XMIN,XMAX (REAL*4) arrays, upper and lower limits on X
  66.           N (INTEGER*2) number of elements in X
  67.           M (INTEGER*2) number of residuals
  68.           W (REAL*4) working space of dimension MW
  69.           MW (INTEGER*2) dimension of working space MW=5N+3M+N*N+N*M
  70.           MCALL (INTEGER*2) maximum function calls (set to zero for unlimited)
  71.           IPRT (INTEGER*2) print select (for IPRT=0 nothing is printed,
  72.           for IPRT=1 only a one line summary at the end is printed, for
  73.           IPRT=2 X, F, and G are printed at each iteration, and for IPRT=3
  74.           the Jacobian is also printed at each iteration)
  75.           need to open file 6 on the PC)
  76. OUTPUT:   X (REAL*4) solution vector
  77.           F (REAL*4) final residual
  78.           IER (INTEGER*2) error indicator
  79.                IER=0  indicates normal return
  80.                IER=1  indicates N<2
  81.                IER=2  indicates M<N
  82.                IER=3  indicates XMIN>XMAX conflict
  83.                IER=4  indicates insufficient work space (increase MW)
  84.           note that the printer output is going to go directly to the
  85.           printer unless you first spool it with by CALLing
  86.           SPOOL('FILE.EXT',IER); and no, the redirect ">" will not work
  87. NOTE:     This is a FAR more difficult problem than most people even
  88.           imagine!  You can compare it to finding the lowest spot on
  89.           the face of the Earth given the rules of the game "Battle
  90.           Ship" where all you can do is call out coordinates and your
  91.           opponent answers with the elevation.  You may find a rut or a
  92.           ditch somewhere; but it's highly unlikely that you will find
  93.           death valley, let alone some trench in the Pacific. Now extend
  94.           this analogy to many-dimensional space... get the point?  So
  95.           don't get too upset if BRYDN can't find the solution you want.
  96.  
  97.           I've tried all sorts of algorithms and this seems to work the
  98.           best for general problems.
  99.  
  100.           If you have 6 equations and 6 unknowns then M=N=6.  If you
  101.           have 12 equations and 6 unknowns then M=12 and N=6.
  102.  
  103.           If all of your equations are linear, by all means don't use BRYDN,
  104.           you want LLSLC.  If you have only one unknown then use FMIN.
  105.  
  106.           For double precision use BRYDND.
  107.  
  108.           Also available are the brute force method (BFNLQ & BFNLQD), the
  109.           conjugate gradient method (CONJG & CONJGD), and Newton's method
  110.           (NTNLQ & NTNLQD). The calling sequence, input, and output are
  111.           all the same as for BRYDN & BRYDND. The only differences is the
  112.           method and the required working space, MW (for BFNLQ, MW=3*N+M;
  113.           for CONJG, MW=8*N+M; and for NTNLQ, MW=6*N+2*M+N*N+N*M).
  114.  
  115.           This is a little tricky, so I have included an example at the end of
  116.           this section.
  117.  
  118.  
  119. NAME:     CUBIC
  120. PURPOSE:  solve a cubic equation
  121. TYPE:     subroutine (far external)
  122. SYNTAX:   CALL SUBROUTINE CUBIC(A1,A2,A3,A4,R1,C1,R2,C2,R3,C3)
  123. INPUT:    A1,A2,A3,A4 (REAL*4) coefficients in cubic equation
  124. OUTPUT:   (R1,C1),(R2,C2),(R3,C3) (REAL*4) roots
  125. NOTE:     the equation has the form A1*X**3+A2*X**2+A3*X+A4=0
  126.           for double precision use CUBICD and don't forget to declare
  127.           A1,A2,A3,A4,R1,C1,R2,C2,R3,C3 all to be REAL*8 and if you
  128.           use constants, don't forget the 1.D0 or whatever.
  129. NOTE:     for double precision use CUBICD
  130.  
  131.  
  132. NAME:     FMIN
  133. PURPOSE:  find the minimum of a function within an interval
  134. TYPE:     REAL*4 function (far external)
  135. SYNTAX:   XMIN=FMIN(F,A,B)
  136. INPUT:    A,B (REAL*4) the search interval
  137.           F (a far external REAL*4 function) that you must supply
  138.           that may be called by FX=F(X)
  139. OUTPUT:   location of minimum
  140. NOTE:     for double precision use FMIND
  141.  
  142.  
  143. NAME:     FZERO
  144. PURPOSE:  find the zero (root) of a function within an interval
  145. TYPE:     REAL*4 function (far external)
  146. SYNTAX:   X0=FZERO(F,A,B)
  147. INPUT:    A,B (REAL*4) interval to look for root in
  148.           F (REAL*4 function) that YOU MUST SUPPLY and must be
  149.           called by the sequence FX=F(X)
  150. OUTPUT:   location of the root
  151. NOTE:     for double precision use FZEROD
  152.  
  153.  
  154. NAME:     GAUSP
  155. PURPOSE:  Gauss-Jordan elimination of simultaneous equations
  156. TYPE:     subroutine (far external)
  157. SYNTAX:   CALL GAUSP(A,B,X,JPIVOT,N,D,C,IER)
  158. INPUT:    A,B (REAL*4) arrays containing the equations to be solved
  159.           having dimensions (N,N) and (N) respectively
  160.           JPIVOT (INTEGER*2) working space of dimension "N"
  161.           N (INTEGER*2) the number of equations
  162. OUTPUT:   X (REAL*4) solution vector of dimension N
  163.           D (REAL*4) ALOG10(ABS(DETERMINANT)) log of the determinant
  164.           C (REAL*4) ALOG10(AMAX1(ABS(PIVOT))/AMIN1(ABS(PIVOT))) a
  165.           measure of the gradedness or condition of the matrix
  166.           IER (INTEGER*2) error indicator (IER=0 is normal)
  167. NOTE:     For double precision use GAUSPD and don't forget to declare
  168.           A,B,X,D,C all to be REAL*8.
  169.           Note that A and B will be destroyed upon return.
  170.           Note that A is in row-order as indicated below
  171.  
  172.